package com.zzjson.quartz;

import org.quartz.*;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <p>****************************************************************************</p>
 * <p><b>Copyright © 2010-2019 shuncom team All Rights Reserved<b></p>
 * <ul style="margin:15px;">
 * <li>Description : com.zzjson.quartz</li>
 * <li>Version     : 1.0.0</li>
 * <li>Creation    : 2019年04月03日</li>
 * <li>@author     : zzy0_0</li>
 * </ul>
 * <p>****************************************************************************</p>
 */
public class HelloJob implements Job {
    private String message;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    /**
     * 编写对应的业务逻辑
     */
    @Override
    public void execute(JobExecutionContext jobExecutionContext) {
        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("Current Exec Time Is: " + simpleDateFormat.format(date));
        JobKey jobKey = jobExecutionContext.getJobDetail().getKey();
        System.out.println(jobKey.getName() + jobKey.getGroup());
        JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
        //for (String s : jobDataMap.keySet()) {
        //    System.out.println(s);
        //    System.out.println(jobDataMap.get(s));
        //}
        TriggerKey triggerKey = jobExecutionContext.getTrigger().getKey();
        System.out.println("startTime" + jobExecutionContext.getTrigger().getStartTime());
        System.out.println("endTime" + jobExecutionContext.getTrigger().getEndTime());
        System.out.println(triggerKey.getName() + triggerKey.getGroup());

        //JobDataMap mergedJobDataMap = jobExecutionContext.getMergedJobDataMap();
        //for (String s : mergedJobDataMap.keySet()) {
        //    System.out.println(s);
        //    System.out.println(mergedJobDataMap.get(s));
        //}
        //System.out.println(mergedJobDataMap);
        //try {
        //    TimeUnit.SECONDS.sleep(5);
        //} catch (InterruptedException e) {
        //    e.printStackTrace();
        //}

        System.out.println(getMessage());

    }
}